<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/course_php.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php ?></title>
<link rel="stylesheet" type="text/css" href="../css/global.css" />
<link rel="stylesheet" type="text/css" href="../css/loggedpages.css" />
<!-- InstanceBeginEditable name="head" -->
<style type="text/css">
	#eventtable {
		width: 580px;
		margin: 2em auto 2em auto;
		border-width: 0;
	}
	
	#eventtable td {
		width: inherit;
		border-top: 1pt solid #d0d0d0;
		padding: 20px 10px 20px 10px;
		font-size: 13px;
	}
	
	td#headrow {
		border-top-width: 0;
		padding: 0 0 10px 0;	
	}
	
	.greenbutton { 
		width: 110px; 
		margin-top: 0;
		padding-right: 15px;
	}
	
	.eventinfo {
		float: left;
		width: 420px;	
	}
	
	.eventname {
		font-size: 14px;
		font-weight: 700;
		margin-bottom: 0.3em;	
	}
	
	.eventdesc { color: #888888; }
	
	.eventact {
		float: right;
		text-align: right;
		width: 120px;	
	}
</style>
<!-- InstanceEndEditable -->
</head>

<body>
	<div class="header">
        <div class="innercontent">
            <img alt="Studial" class="logo" src="../images/logo.jpg" />   
            <form id="searchform" method="post" action="">
                <div id="searchblock">
                    <input id="searchfield" name="searchfield" type="text" placeholder="Tìm kiếm" />
                    <button id="searchbutton" type="submit" name="search" value="1" title="Tìm kiếm" onclick="window.location = '../unlogged/index.php'"><img id="searchicon" src="../images/searchicon.png" /></button>
                </div>           
            </form>
            <div id="rightheader">
                <a class="headerbutton" id="logout"><span id="borderleft"></span>Đăng xuất</a>
                <a class="headerbutton" id="toboard"><?php echo "Username" ?></a>
            </div>
        </div>
    </div>
    <div class="innercontent">
        <div id="leftcolumn">
            <img alt="Avatar" id="largeavatar" src="<?php echo $path = "../images/male_avatar.png"; ?>" />
        	<div id="sidenavcontainer">	
                <ul id="sidenav">
            		<li><a class="navlink" href=""><span id="boardnav">Bảng</span></a></li>
                    <li><a class="navlink" href=""><span id="eventnav">Sự kiện</span></a></li>
                    <li><a class="navlink" href=""><span id="membernav">Thành viên</span></a></li>
                    <?php if (1) echo "<li><a class=\"navlink\" href=\"\"><span id=\"gradenav\">Bảng điểm</span></a></li>"; ?>
            	</ul>
            </div>
        </div>
        <div id="contentcolumn">
        	<div id="contentcolheader">
            	<h2>Coursename</h2>
                <div id="description">Description</div>
            </div>
		<!-- InstanceBeginEditable name="maincontent" -->
        <?php
			$username = $_COOKIE['studialusername'];
			$password = $_COOKIE['studialuserpwd'];
			$userid = $_COOKIE['studialuserid'];
			$CourseID = $_GET['courseid'];
			
			@ $db = mysql_pconnect("localhost","root","");
			
			if(!$db)
			{
				echo "<h2>Database does not exist!</h2>";
				exit;
			}
			
			$selectEvent = "SELECT * FROM `assignments` WHERE course_id = '".$CourseID."'";
			$resultEvent = mysql_query($selectEvent);
			$rowEvent = mysql_fetch_array($resultEvent);
			$numEvent = mysql_num_rows($resultEvent);
			
			$selectAssignment = "SELECT * FROM `assignments` a INNER JOIN `assignment_submission` as ON a.id = as.assgnment_id WHERE course_id = '".$CourseID."' AND user_id = ".$userid."'";
			$resultAssignment = mysql_query($selectAssignment);
			$rowAssignment = mysql_fetch_array($resultAssignment);
			
			echo '<table id="eventtable">';
			echo '	<tr>';
			echo '		<td id="headrow"><a href="../createEvent.php"><button class="greenbutton">+ Tạo sự kiện</button></a></td>';
			echo '	</tr>';
			for($i=1; $i<=$numEvent; $i++)
			{
				echo '<tr>';
				echo '	<td>';
				echo '		<div class="eventinfo">';
				echo '			<div class="eventname"><a href="../viewEvent.php?id=">'.stripslashes($rowEvent['name']).'</a></div>';
				echo '			<div class="eventdesc">'.stripslashes($rowEvent['finishdate']).'</div>';
				echo '			<div class="eventstate">';
				if($i == 1)
				{
					echo 'Đã nộp bài lúc '.stripslashes($rowAssignment['datesubmitted']);
				}
				echo '			</div>';
				echo '		</div>';
				echo '		<div class="eventact">';
				if ($i ==3 || $i ==2)
				{
					echo '<a href="../removeEvent.php?id=">Xóa khóa học</a>';
				}
				echo '		</div>';
				echo '	</td>';
				echo '</tr>';
			}
			echo '</table>';
		?>
		<!-- InstanceEndEditable -->
    	</div>
    </div>
    <div class="footer">
    	<div id="leftfooter">Studial @ 2012 - Nhóm 01</div>
        <div id="rightfooter">
			<a href="" title="Đăng ký thêm tên trường vào hệ thống">Đăng ký trường</a>
            -
            <a href="" title="Đăng ký thêm tên ngành học vào hệ thống">Đăng ký ngành</a>
        </div>
    </div>       
</body>
<!-- InstanceEnd --></html>
